/*
 * @Descripttion: ---
 * @version: v1.0.0.0
 * @Author: 任飞
 * @Date: 2020-06-25 11:33:44
 * @LastEditors: 任飞
 * @LastEditTime: 2020-07-08 00:46:57
 */ 
import createAPI from '@/utils/axios'
// import { config } from 'vue/types/umd'

const fenxiao = {
  // 公司管理相关API
  companyUser: {
    find: (userNo, roleCode) => createAPI(`/admin/sysCompanyUser/listByUserAndRoleCode/${userNo}/${roleCode}`, 'POST', {}),
    save: config => createAPI('/admin/sysCompanyUser/save', 'POST', config),
    del: id => createAPI(`/admin/sysCompanyUser/del/${id}`, 'POST', {})
  },
  // 公司管理相关API
  company: {
    find: config => createAPI('/admin/sysCompany/listPage', 'POST', config),
    create: config => createAPI('/admin/sysCompany/create', 'POST', config),
    update: config => createAPI('/admin/sysCompany/update', 'POST', config),
    del: id => createAPI(`/admin/sysCompany/del/${id}`, 'POST', {}),
    types: pDictCode => createAPI(`/common/dict/findByPdictCode/${pDictCode}`, 'GET', {}),
    listAll: config => createAPI('/admin/sysCompany/listAll', 'POST', config),
  },
  // 用户管理相关API
  user: {
    find: config => createAPI('/admin/user/listPage', 'POST', config),
    create: config => createAPI('/admin/user/create', 'POST', config),
    update: config => createAPI('/admin/user/update', 'POST', config),
    del: id => createAPI(`/admin/user/delete/${id}`, 'POST', {}),
    types: pDictCode => createAPI(`/common/dict/findByPdictCode/${pDictCode}`, 'GET', {}),
    getUserDetail: userNo => createAPI(`/admin/sysUserRole/${userNo}`, 'GET', {}),
    modiPass: config => createAPI('/common/login/modiPass', 'POST', config)
  },
  // 角色管理相关API
  role: {
    find: config => createAPI('/admin/sysRole/listPage', 'POST', config), // 角色分页查询
    create: config => createAPI('/admin/sysCompany/create', 'POST', config),
    update: config => createAPI('/admin/sysCompany/update', 'POST', config),
    add: config => createAPI('/admin/sysRole/create', 'POST', config),
    del: id => createAPI(`/admin/sysCompany/del/${id}`, 'POST', {}),
    types: pDictCode => createAPI(`/common/dict/findByPdictCode/${pDictCode}`, 'GET', {}),
    delRole: id => createAPI(`/admin/sysRole/del/${id}`, 'POST', {}),
    // 根绝角色编码或者用户号获取资源授权信息
    listTreeBySourceCode: sourceCode => createAPI(`/admin/sysResourcePermit/listTreeBySourceCode/${sourceCode}`, 'GET', {}),
    // 创建用户角色
    createRole: config => createAPI('/admin/sysUserRole/save', 'POST', config),

  },
  // 资源管理相关API
  menu: {
    find: config => createAPI('/admin/sysCompany/listPage', 'POST', config),
    create: config => createAPI('/admin/sysCompany/create', 'POST', config),
    update: config => createAPI('/admin/sysCompany/update', 'POST', config),
    del: id => createAPI(`/admin/sysCompany/del/${id}`, 'POST', {}),
    types: pDictCode => createAPI(`/common/dict/findByPdictCode/${pDictCode}`, 'GET', {}),
    listTree: config => createAPI('/admin/sysResource/listTree', 'POST', config),
    saveMenu: config => createAPI('/admin/sysResourcePermit/save/', 'POST', config), //保存资源授权
    createMenu: config => createAPI('/admin/sysResource/create', 'POST', config), //创建菜单资源
    delMenu: id => createAPI(`/admin/sysResource/del/${id}`, 'POST', {}), //删除菜单资源
    editMenu: config => createAPI('/admin/sysResource/update', 'POST', config), //编辑菜单资源

  },
  // 商品相关API
  
  product: {
    find: config => createAPI('/admin/itemCat/listPage', 'POST', config),
    create: config => createAPI('/admin/itemCat/create', 'POST', config),
    update: config => createAPI('/admin/item/modiGoods', 'POST', config),
    del: id => createAPI(`/admin/itemCat/del/${id}`, 'POST', {}),
    types: pDictCode => createAPI(`/common/dict/findByPdictCode/${pDictCode}`, 'GET', {}),
    classify: shopNo => createAPI(`/app/user/itemCat/findItemCat/${shopNo}`, 'GET', {}),
    add: config => createAPI('/admin/item/addGoods', 'POST', config),
    edit: config => createAPI('/admin/itemCat/modi', 'POST', config),
    upOrDown: itemNo => createAPI('/admin/item/upOrDown/' + itemNo, 'POST', {}), // 商品上架/下架
    findGoodsByItemNo: itemNo => createAPI(`/admin/item/findGoodsByItemNo/${itemNo}`, 'GET', {}), // 商品详情
  },
  // 费用项相关
  bill: {
    create: config => createAPI('/admin/billItem/create', 'POST', config),
    del: id => createAPI(`/admin/billItem/del/${id}`, 'POST', {}), // 查寻
    update: config => createAPI('/admin/billItem/update', 'POST', config),
  },
  // 订单相关
  order: {
    export: config => createAPI('/admin/order/export', 'GET', config),
    find: config => createAPI('/admin/order/listPage', 'POST', config), // 查寻
    check: config => createAPI('/admin/order/confirmMoneyBatch', 'POST', config), // 审核
    detail: orderNo => createAPI(`/admin/order/findOrderByNo/${orderNo}`, 'GET', {}),
    sendGoods: config => createAPI(`/admin/order/sendGoods`, 'POST', config),//发货
    cancelBatch: config => createAPI(`/admin/order/cancelBatch`, 'POST', config),
    batchDelete: config => createAPI(`/admin/order/delBatch`, 'POST', config)
  },
  promGroup:{
    detail: groupNo => createAPI(`/admin/promGroup/findByGroupNo/${groupNo}`, 'GET', {}),
  },
  // 结算单相关
  settleTotal: {
    check: config => createAPI('/admin/settleTotal/aduit', 'POST', config), // 审核
  },
  // 提现相关
  withdraw: {
    check: config => createAPI('/admin/withDraw/aduit', 'POST', config), // 审核
  },
  // 词典相关
  // 词典相关
  sysDict: {
    deleteById: id => createAPI(`/admin/sysDict/deleteById/${id}`, 'GET', {}), //按照ID删除数据
    findById: id => createAPI(`/admin/sysDict/findById/${id}`, 'GET', {}), //按照字典id查询字典数据
    findByPdictCode: code => createAPI(`/admin/sysDict/findByPdictCode/${code}`, 'GET', {}), //按照上级字典编码查询下级字典
    listPDictAll: config => createAPI('/admin/sysDict/listPDictAll', 'POST', config), // 查询所有一级字典数据
    insert: config => createAPI('/admin/sysDict/insert', 'POST', config), // 新增数据字典
    update: config => createAPI('/admin/sysDict/update', 'POST', config), // 修改数据字典
    listPage: config => createAPI('/admin/sysDict/listPage', 'POST', config), // 按照查询条件查询字典数据
  },
  // 上传图片
  upload: {
    uploadImg: config => createAPI('/common/file/uploadFile', 'POST', config),
  }
}

export default fenxiao